//
//  JaneWebViewController.m
//  EPA
//
//  Created by lanou3g on 16/4/23.
//  Copyright © 2016年 张静. All rights reserved.
//

#import "JaneWebViewController.h"
#import "JaneNetWorkRequestManager.h"
#import "JaneBaseTopicModel.h"
#import "JaneCommentController.h"
@interface JaneWebViewController ()
@property (nonatomic,strong) NSString *urlStr;
@property (nonatomic,strong) UIWebView *webView;
@end

@implementation JaneWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadFromServerContentID:nil];
    
        // Do any additional setup after loading the view.
}

- (void) loadFromServerContentID:(NSString *)contentid {
    [JaneNetWorkRequestManager requestURL:[NSURL URLWithString:TOPICINFO_URL] RequestMethod:CK_POST Params:@{@"contentid":self.listModel.contentid,@"client":@"1",@"deviceid":@"63A94D37-33F9-40FF-9EBB-481182338873",@"auth":@"Wc06FCrkoq1DCMVzGMTikDJxQ8bm3Mrm2NpT9qWjwzcWP23tBKQx1c4P0",@"version":@"3.0.2"} Result:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (data) {
            NSMutableDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSDictionary *dataDict = jsonDict[@"data"];
           NSDictionary *postDict = dataDict[@"postsinfo"];
            NSDictionary *shareinfoDict = postDict[@"shareinfo"];
            self.urlStr = shareinfoDict[@"url"];
            }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self createWebView];
        });

    }];
}

- (void)createWebView {
    self.webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:self.webView];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
